<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace app\adminapi\controller\v1\setting;

use app\adminapi\services\setting\SystemAdminService;
use kitego\base\BaseController;
use think\App;
use think\db\exception\DbException;
use think\response\Json;

class SystemAdminController extends BaseController
{
    public array $safeAction = [];

    private SystemAdminService $service;

    public function __construct(App $app, SystemAdminService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    /**
     * 申请成为管理员
     */
    public function applySystemAdmin(): Json
    {
        return $this->service->applySystemAdmin($this->params);
    }

    /**
     * 管理员列表
     * @throws DbException
     */
    public function listSystemAdmin(): Json
    {
        $this->params['page'] = $this->params['page'] ?? 1;
        $this->params['pageSize'] = $this->params['pageSize'] ?? 10;

        return $this->service->listSystemAdmin($this->params);
    }

    /**
     * 编辑员工
     * @throws DbException
     */
    public function editSystemAdmin(): Json
    {
        return $this->service->editSystemAdmin($this->params);
    }

    /**
     * 批量删除员工
     * @throws DbException
     */
    public function batchDelSystemAdmin(): Json
    {
        return $this->service->batchDelSystemAdmin($this->params);
    }
}